package com.solo.system.dubbo;

import com.mybatisflex.core.query.QueryChain;
import com.solo.system.api.SysI18nTypeApi;
import com.solo.system.mapper.SysI18nTypeMapper;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.solo.system.api.entity.table.SysI18nTypeTableDef.SysI18nTypeTable;

/**
 * 国际化语言类型api接口实现
 * @author 十一
 * @since 2024/12/02
 * 人生若只如初见，何事秋风悲画扇
 **/
@Service
@DubboService
@RequiredArgsConstructor
public class SysI18nTypeApiImpl implements SysI18nTypeApi {
    
    private final SysI18nTypeMapper sysI18nTypeMapper;

    @Override
    public List<String> queryLanguage() {
        return QueryChain.of(sysI18nTypeMapper)
                .select(SysI18nTypeTable.Name)
                .where(SysI18nTypeTable.Status.eq(true))
                // 降序，将默认的语言类型放在第一个
                .orderBy(SysI18nTypeTable.IsDefault.desc())
                .listAs(String.class);
    }

}
